<?php
$teamId = isset($_GET['id'])?$_GET['id']:'-1';
?>
<script type="text/javascript">
function confirmDelete(id) {
	var r=confirm("Biztos, hogy törlöd a képet?");
	
	if (r==true) {
		document.deleteForm.imageId.value = id;
		document.deleteForm.submit();
	}
}
</script>
<?php 
include "classes/db/dbmanager.php";
$pDatabase = Database::getInstance();
$sql="SELECT * FROM team WHERE id = ".$teamId;
$result = $pDatabase->query($sql);
$row = mysql_fetch_array($result)
?>
<h2>Kép feltöltése (<?php echo $row["teamName"]?>)</h2>
<br/>
<form name="deleteForm" action="classes/db/delete.php">
<input type="hidden" id="imageId" name="imageId" value="">
<input type="hidden" id="teamId" name="teamId" value="<?php echo $teamId?>">
<input type="hidden" id="objectType" name="objectType" value="image">
</form>
<form class="form-horizontal" name="form" action="classes/db/insertimage.php" method="post" enctype="multipart/form-data">
<input type="hidden" id="teamId" name="teamId" value="<?php echo ($teamId)?>">
<div class="control-group">
    <label class="control-label" for="teamName">Fénykép</label>
    <div class="controls">
      <input type="file" name="file">
    </div>
  </div>
  
  <div class="control-group">
    <label class="control-label" for="imageDesc_hu">Kép leírás (magyar)</label>
    <div class="controls">
      <input type="text" id="imageDesc_hu" name="imageDesc_hu" value="">
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="imageDesc_en">Kép leírás (angol)</label>
    <div class="controls">
      <input type="text" id="imageDesc_en" name="imageDesc_en" value="">
    </div>
  </div>
  <div class="control-group">
    <div class="controls">
    <input type="submit" name="submit" value="Mentés" class="btn"/>
    </div>
  </div>
<?php 
$sql="SELECT * FROM image where teamId = ".$teamId;
$result = $pDatabase->query($sql);
while($row = mysql_fetch_array($result)) {?>
	<div class="row">
	<img src="<?php echo Config::IMAGE_DIR.$row["imageName"]; ?>" width="150" height="100">
	<a href="<?php echo "javascript:confirmDelete(".$row["id"].")"?>"><img title="Kép törlése" src="img/icon_delete.png" height="20" width="20"/></a>
	<br/>
	<br/>
	<br/>
	</div>
	<?php 
}
?>


</form>